package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.anno.AtuoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import com.sky.result.PageResult;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 更新员工密码
     * @param emp
     */
    // 加更新方法
    @Update("update employee set password = #{password} where id = #{id}")
    void updateById(Employee emp);

    /**
     * 新增员工
     * @param emp
     */
    @AtuoFill(OperationType.INSERT)
    @Insert("insert into employee values (null,#{name}, #{username}, #{password}, #{phone}, #{sex}, " +
            "#{idNumber}, #{status}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void addEmp(Employee emp);
    /**
     * 分页查询员工
     * @param name
     * @return
     */
    Page<Employee> list(String name);

     /**
      * 根据id查询员工
      * @param id
      * @return
      */
    @Select("select * from employee where id = #{id}")
    Employee selectById(Long id);
    /**
     * 更新员工状态包括更新员工
     * @param employee
     */
    @AtuoFill(OperationType.UPDATE)
    void updatestatus(Employee employee);
}
